#include <material_editor/basematerialeditor.h>

BaseMaterialEditorWidget::BaseMaterialEditorWidget(QWidget *parent)
  : BaseEditorWidget (parent)
  , _item(0)
{
}


void BaseMaterialEditorWidget::SetItem(MaterialData *item)
{
  if (item == _item)
    {
      return;
    }

  if (_item)
    {
      disconnect(_item, SIGNAL(Changed()), this, SLOT(Changed ()));
      disconnect (_item, SIGNAL(NameChanged()), this, SLOT(NameChanged()));
    }

  _item = item;
  Changed ();
  connect (_item, SIGNAL(Changed()), this, SLOT(Changed()));
  connect (_item, SIGNAL(NameChanged()), this, SLOT(Changed()));

}

void* BaseMaterialEditorWidget::GetData ()
{
  return _item;
}

void BaseMaterialEditorWidget::Changed()
{
  SetName(_item->GetFullname());
}
